package com.hb.core.pojo.enums;

import lombok.Getter;

/**
 * 标段状态枚举类2222
 */
@Getter
public enum SectionStatusEnum {

    PROJECT_SAVED(1465922770142670848L, 144, "项目信息已保存"),
    NOTICE_DEPLOYED(1465922770142670849L, 146, "公告/邀请书已发布"),
    BID_FILE_SOLD(1465922770142670850L, 147, "文件已发售"),
    BID_OPENING(1465922770146865152L, 148, "开标中"),
    BID_ASSESSING(1465922770146865153L, 149, "评标中"),
    CANDIDATE_NOTICE_DEPLOYED(1465922770146865157L, 150, "中标候选人公示已发布"),
    WIN_BID_NOTICE_DEPLOYED(1465922770146865156L, 151, "中标公示已发布"),

    @Deprecated
    OPEN_BID_END(1465922770146865154L, 148, "开标结束"),
    @Deprecated
    BID_ASSESS_END(1465922770146865155L, 150, "评标结束"),

    FAIL_AUCTION(1465922770146865158L, -1, "流标");

    /**
     * 状态Id，对应字典表主键
     */
    private final Long id;

    /**
     * 序号，对应字段表排序
     * 可作为排序使用
     */
    private final Integer code;

    /**
     * 名称
     */
    private final String showName;

    SectionStatusEnum(Long id, Integer code, String showName) {
        this.id = id;
        this.code = code;
        this.showName = showName;
    }

    /**
     * 通过状态Id查询状态序号
     *
     * @param sectionStatusId 状态Id
     * @return
     */
    public static Integer getCodeById(Long sectionStatusId) {
        SectionStatusEnum ins = getIns(sectionStatusId);
        if (ins == null) {
            return 0;
        }
        return ins.code;
    }

    /**
     * 获取标段状态枚举实例
     *
     * @param sectionStatusId
     * @return
     */
    public static SectionStatusEnum getIns(Long sectionStatusId) {
        if (sectionStatusId == null) {
            return null;
        }
        SectionStatusEnum[] values = SectionStatusEnum.values();
        for (SectionStatusEnum sectionStatus : values) {
            if (sectionStatusId.equals(sectionStatus.getId())) {
                return sectionStatus;
            }
        }
        return null;
    }
}
